#pragma once
#include "dx_common.h"
#include <d3d12_core.h>

namespace d3d12
{
	struct CommandFrame
	{
		ID3D12CommandAllocator* allocator;
		ID3D12GraphicsCommandListN* cmd_list;
		u64 local_fence_value;
		HANDLE local_fence_event;
	};

	class Command
	{
	public:
		Command();
		~Command();
		ID3D12GraphicsCommandListN* Begin(ID3D12PipelineState* pip = nullptr);
		void WaitFrame(HANDLE e, u64 fv);
		void Flush();
		void End();
		bool SurfaceCreate(Surface& sur, HWND winid);
		void SurfaceResize(Surface& sur, u32 width, u32 height);
		void SurfaceDestory(Surface& sur);
		void SurfacePresentBegin(Surface& sur, ID3D12GraphicsCommandListN* list);
		void SurfacePresentEnd(Surface& sur);

	private:
		CommandFrame frames[COMMAND_FRAME_COUNT];
		u32 frame_index;
		ID3D12Fence* fence;
		u64 fence_value;
	};
}